package wordroid.activitys;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Bundle;
 
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import wordroid.database.DataAccess;
import wordroid.model.Word;
import wordroid.model.WordList;

public class Review extends Activity
  implements View.OnClickListener
{
  private Button add;
  private int currentnum;
  private TextView info;
  private ArrayList<Word> list = new ArrayList();
  private String listnum;
  private Button nextone;
  private Button notremember;
  private Button remember;
  private Button right;
  private ImageButton speak;
  private TextView spelling;
  private TextToSpeech tts;
 // private TextToSpeech.OnInitListener ttsInitListener = new 1(this);
//  private TextToSpeech.OnUtteranceCompletedListener ttsUtteranceCompletedListener = new OnUtteranceCompletedListener( );
  private Button wrong;

  private void UpdateView()
  {
    if (this.currentnum < this.list.size())
    {
      if (getSharedPreferences("wordroid.model_preferences", 0).getBoolean("iftts", false))
     //   new Thread(new 3(this)).start();
      this.spelling.setText(((Word)this.list.get(this.currentnum)).getID() + "." + ((Word)this.list.get(this.currentnum)).getSpelling());
      this.info.setText(((Word)this.list.get(this.currentnum)).getPhonetic_alphabet() + "\n 请尽力回想单词中文意思...");
      this.remember.setVisibility(0);
      this.notremember.setVisibility(0);
      this.right.setVisibility(8);
      this.wrong.setVisibility(8);
      this.nextone.setVisibility(8);
    }
    while (true)
    {
      
      DataAccess localDataAccess = new DataAccess(this);
      WordList localWordList = (WordList)localDataAccess.QueryList("BOOKID ='" + DataAccess.bookID + "'AND LIST = '" + this.listnum + "'", null).get(0);
      localWordList.setShouldReview("0");
      localWordList.setReview_times(String.valueOf(1 + Integer.parseInt(localWordList.getReview_times())));
      Calendar localCalendar = Calendar.getInstance();
      localWordList.setReviewTime(new SimpleDateFormat("yyyy-MM-dd").format(localCalendar.getTime()));
      localDataAccess.UpdateList(localWordList);
      new AlertDialog.Builder(this).setIcon(2130837509).setTitle("复习已完成").setMessage("您可以在复习计划中查看下次复习时间！").setPositiveButton("确定", null).create().show();
      return;
    }
  }

  private void initWidgets()
  {
    this.add = ((Button)findViewById(2131165228));
    this.add.setOnClickListener(this);
    this.info = ((TextView)findViewById(2131165227));
    this.nextone = ((Button)findViewById(2131165233));
    this.nextone.setOnClickListener(this);
    this.notremember = ((Button)findViewById(2131165230));
    this.notremember.setOnClickListener(this);
    this.remember = ((Button)findViewById(2131165229));
    this.remember.setOnClickListener(this);
    this.right = ((Button)findViewById(2131165231));
    this.right.setOnClickListener(this);
    this.spelling = ((TextView)findViewById(2131165226));
    this.wrong = ((Button)findViewById(2131165232));
    this.wrong.setOnClickListener(this);
    Typeface localTypeface = Typeface.createFromAsset(getAssets(), "fonts/SEGOEUI.TTF");
    this.info.setTypeface(localTypeface);
    this.speak = ((ImageButton)findViewById(2131165225));
    this.speak.setOnClickListener(this);
   // this.tts = new TextToSpeech(this, this.ttsInitListener);
    new DisplayMetrics();
    int i = getApplicationContext().getResources().getDisplayMetrics().widthPixels;
    this.add.setWidth(i / 3);
    this.nextone.setWidth(2 * i / 3);
    this.notremember.setWidth(i / 3);
    this.remember.setWidth(i / 3);
    this.right.setWidth(i / 3);
    this.wrong.setWidth(i / 3);
  }

  public void onClick(View paramView)
  {
   // if (paramView == this.speak)
     // this.tts.speak(((Word)this.list.get(this.currentnum)).getSpelling(), 1, null);
    if (paramView == this.remember)
    {
      this.wrong.setVisibility(0);
      this.right.setVisibility(0);
      this.remember.setVisibility(8);
      this.notremember.setVisibility(8);
      this.info.setText(((Word)this.list.get(this.currentnum)).getPhonetic_alphabet() + "\n" + ((Word)this.list.get(this.currentnum)).getMeanning());
    }
    if (paramView == this.notremember)
    {
      this.nextone.setVisibility(0);
      this.remember.setVisibility(8);
      this.notremember.setVisibility(8);
      this.info.setText(((Word)this.list.get(this.currentnum)).getPhonetic_alphabet() + "\n" + ((Word)this.list.get(this.currentnum)).getMeanning());
    }
    if (paramView == this.right)
    {
      this.currentnum = (1 + this.currentnum);
      UpdateView();
    }
    if ((paramView == this.wrong) || (paramView == this.nextone))
    {
      new Word();
      Word localWord = (Word)this.list.get(this.currentnum);
      this.list.add(localWord);
      this.currentnum = (1 + this.currentnum);
      UpdateView();
    }
    if (paramView == this.add)
    {
      DataAccess localDataAccess = new DataAccess(this);
      new ArrayList();
      if (localDataAccess.QueryAttention("SPELLING ='" + ((Word)this.list.get(this.currentnum)).getSpelling() + "'", null).size() != 0)
     //   break label428;
      localDataAccess.InsertIntoAttention((Word)this.list.get(this.currentnum));
      Toast.makeText(this, "已加入生词本", 0).show();
    }
    while (true)
    {
    	label428: Toast.makeText(this, "生词本中已包含这个单词！", 0).show();
      return;
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903053);
    this.currentnum = 0;
    new Bundle();
    this.listnum = getIntent().getExtras().getString("list");
    setTitle("复习LIST-" + this.listnum);
    this.list = new DataAccess(this).QueryWord("LIST = '" + this.listnum + "'", null);
    initWidgets();
    UpdateView();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 4)
      new AlertDialog.Builder(this).setIcon(2130837509).setTitle("复习未完成").setMessage("你确定现在结束复习吗？这将导致本次复习无效！").setPositiveButton("确定", null).setNegativeButton("取消", null).create().show();
    return true;
  }
}

/* Location:           E:\Desktop\Android\英语词汇记忆\classes_dex2jar.jar
 * Qualified Name:     wordroid.activitys.Review
 * JD-Core Version:    0.5.3
 */